﻿using System;

namespace MessagePack.Formatters
{
	// Token: 0x0200004C RID: 76
	public class NullableSByteFormatter : IMessagePackFormatter<sbyte?>
	{
		// Token: 0x0600011F RID: 287 RVA: 0x00004B6E File Offset: 0x00002F6E
		private NullableSByteFormatter()
		{
		}

		// Token: 0x06000120 RID: 288 RVA: 0x00004B76 File Offset: 0x00002F76
		public int Serialize(ref byte[] bytes, int offset, sbyte? value, IFormatterResolver formatterResolver)
		{
			if (value == null)
			{
				return MessagePackBinary.WriteNil(ref bytes, offset);
			}
			return MessagePackBinary.WriteSByte(ref bytes, offset, value.Value);
		}

		// Token: 0x06000121 RID: 289 RVA: 0x00004BA0 File Offset: 0x00002FA0
		public sbyte? Deserialize(byte[] bytes, int offset, IFormatterResolver formatterResolver, out int readSize)
		{
			if (MessagePackBinary.IsNil(bytes, offset))
			{
				readSize = 1;
				return null;
			}
			return new sbyte?(MessagePackBinary.ReadSByte(bytes, offset, out readSize));
		}

		// Token: 0x04000040 RID: 64
		public static readonly NullableSByteFormatter Instance = new NullableSByteFormatter();
	}
}
